//
//  ChooseImageView.m
//  XDBaseFrameWork
//
//  Created by xindao on 14-9-25.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "ChooseImageView.h"

@implementation ChooseImageView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        _contentIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 104, 104)];
        _contentIV.backgroundColor = UIColorFromRGB(0xeaeaea);
        _contentIV.layer.masksToBounds = YES;
        _contentIV.userInteractionEnabled = YES;
        _contentIV.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:_contentIV];

        UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoDetail:)];
        [_contentIV addGestureRecognizer:tap];

        _selectBtn = [UIButton initButton:CGRectMake(74, 0, 30, 30) btnNorImage:nil btnHighlightImage:nil btnTitle:nil titleColor:nil titleFont:nil];
        [_selectBtn setBackgroundImage:[UIImage imageNamed:@"duigou_sel"] forState:UIControlStateSelected];
        [_selectBtn setBackgroundImage:[UIImage imageNamed:@"duigou_disel"] forState:UIControlStateNormal];
        [_selectBtn addTarget:self action:@selector(selectImage:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_selectBtn];

    }
    return self;
}

- (void)selectImage:(UIButton *)sender{
    _selectBtn.selected = !_selectBtn.selected;
    [_delegate chooseImageView:sender];
}

- (void)gotoDetail:(UIGestureRecognizer *)tap{
    [_delegate gotoDetail:tap];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
